package router

// by daoyi
import (
	"github.com/gin-gonic/gin"
	"simai_oa/controller/admin"
	"simai_oa/middlewares"
)

func AdminRoutesInit(router *gin.Engine) {

	router.GET("/admin/login/captcha", admin.Captcha)                //获取验证码
	router.POST("/admin/login/index", admin.LoginController{}.Index) //后台登陆页
	adminRoutes := router.Group("/admin")
	//中间件 包含jwt中间件
	adminRoutes.Use(middlewares.InitMiddlewares)
	{
		//文件上传页面
		//adminRoutes.GET("/upload", admin.UploadController{}.Index)
		////文件上传
		//adminRoutes.POST("/upload/doUpload", admin.UploadController{}.DoUpload)
		//adminRoutes.POST("/upload/duoup", admin.UploadController{}.DuoUp)
		//adminRoutes.POST("/upload/duoupname", admin.UploadController{}.DuoUpName)
		menu := admin.Menu{}
		adminRoutes.GET("/menu/list", menu.List)
		adminRoutes.GET("/menu/detail", menu.Detail)
		adminRoutes.GET("/menu/allmenu", menu.AllMenu)
		adminRoutes.POST("/menu/delete", menu.Delete)
		adminRoutes.POST("/menu/update", menu.Update)
		adminRoutes.POST("/menu/create", menu.Create)
		user := admin.User{}
		adminRoutes.GET("/user/info", user.Info)
		//adminRoutes.POST("/login/login", user.Login)
		//adminRoutes.POST("/login/logout", user.Logout)
		adminRoutes.POST("/login/editpwd", user.EditPwd)
		admins := admin.Admins{}
		adminRoutes.GET("/admins/list", admins.List)
		adminRoutes.GET("/admins/detail", admins.Detail)
		adminRoutes.GET("/admins/adminsroleidlist", admins.AdminsRoleIDList)
		adminRoutes.POST("/admins/delete", admins.Delete)
		adminRoutes.POST("/admins/update", admins.Update)
		adminRoutes.POST("/admins/create", admins.Create)
		adminRoutes.POST("/admins/setrole", admins.SetRole)
		role := admin.Role{}
		adminRoutes.GET("/role/list", role.List)
		adminRoutes.GET("/role/detail", role.Detail)
		adminRoutes.GET("/role/rolemenuidlist", role.RoleMenuIDList)
		adminRoutes.GET("/role/allrole", role.AllRole)
		adminRoutes.POST("/role/delete", role.Delete)
		adminRoutes.POST("/role/update", role.Update)
		adminRoutes.POST("/role/create", role.Create)
		adminRoutes.POST("/role/setrole", role.SetRole)

		//文件上传页面
		upload := admin.Upload{}
		adminRoutes.GET("/upload", upload.Index)
		//文件上传
		adminRoutes.POST("/upload/doUpload", upload.DoUpload)
		adminRoutes.POST("/upload/duoup", upload.DuoUp)
		adminRoutes.POST("/upload/duoupname", upload.DuoUpName)
	}
}
